﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using QLTV_Public;
namespace QLTV_Data
{
   public class TaiLieu_Data
    {
       KetNoiCSDL_Data kn=new KetNoiCSDL_Data();
       public DataTable LayDuLieu()
       {
           return kn.LayDuLieu("Load_tbl_TaiLieu");
       }
       public DataTable Load_TimKiem()
       {
           return kn.LayDuLieu("Load_TimKiem_MuonTaiLieu");
       }
       public DataTable TimKiem_MuonTaiLieu(MuonTra_Public maphieuMuon,PhieuMuon_Public maDocGia,TaiLieu_Public tenTaiLieu)
       {
           int Nparameter = 3;
           string[]name=new string[Nparameter];
           object[] value = new object[Nparameter];
           name[0] = "@MaPhieuMuon";
           value[0] = maphieuMuon.MaPhieuMuon;
           name[1] = "@MaDocGia";
           value[1] = maDocGia.MaDocGia;
           name[2] = "@TenTaiLieu";
           value[2] = tenTaiLieu.TenTaiLieu;
           return kn.LayDuLieu("TimKiem_MuonTaiLieu",name,value,Nparameter);
       }
       public DataTable TaoBang(string sql)
       {
           return kn.taobang(sql);
       }
       public int insert_TaiLieu(TaiLieu_Public tenTaiLieu, TaiLieu_Public tacGia, TaiLieu_Public maTheLoai, TaiLieu_Public maNhaXuatBan, TaiLieu_Public namXuatBan, TaiLieu_Public noiDung, TaiLieu_Public maNgonNgu, TaiLieu_Public soTrang, TaiLieu_Public lanTaiBan, TaiLieu_Public giaBia, TaiLieu_Public soLuong, /*TaiLieu_Public tinhTrang*/ TaiLieu_Public maViTri, TaiLieu_Public ngayCapNhat)
       {
           int Nparametter=13;
           string[]name= new string[Nparametter];
           object[]value=new object[Nparametter];
           name[0] = "@TenTaiLieu";
           value[0] = tenTaiLieu.TenTaiLieu;
           name[1] = "@TacGia";
           value[1] = tacGia.TacGia;
           name[2] = "@MaTheLoai";
           value[2] = maTheLoai.MaTheLoai;
           name[3] = "@MaNhaXuatBan";
           value[3] = maNhaXuatBan.MaNhaXuatBan;
           name[4] = "@NamXuatBan";
           value[4] = namXuatBan.NamXuatBan;
           name[5] = "@NoiDung";
           value[5] = noiDung.NoiDung;
           name[6] = "@MaNgonNgu";
           value[6] = maNgonNgu.MaNgonNgu;
           name[7] = "@SoTrang";
           value[7] = soTrang.SoTrang;
           name[8] = "@LanTaiBan";
           value[8] = lanTaiBan.LanTaiBan;
           name[9] = "@GiaBia";
           value[9] = giaBia.GiaBia;
           name[10] = "@SoLuong";
           value[10] = soLuong.SoLuong;
           //name[11] = "@TinhTrang";
           //value[11] = tinhTrang.TinhTrang;
           name[11] = "@MaViTri";
           value[11] = maViTri.MaViTri;
           name[12] = "@NgayCapNhat";
           value[12] = ngayCapNhat.NgayCapNhat;
           return kn.update("Insert_TaiLieu", name, value, Nparametter);
       }
       public int update_TaiLieu(TaiLieu_Public maTaiLieu,TaiLieu_Public tenTaiLieu, TaiLieu_Public tacGia, TaiLieu_Public maTheLoai, TaiLieu_Public maNhaXuatBan, TaiLieu_Public namXuatBan, TaiLieu_Public noiDung, TaiLieu_Public maNgonNgu, TaiLieu_Public soTrang, TaiLieu_Public lanTaiBan, TaiLieu_Public giaBia, TaiLieu_Public soLuong,/* TaiLieu_Public tinhTrang*/ TaiLieu_Public maViTri, TaiLieu_Public ngayCapNhat)
       {
           int Nparametter = 14;
           string[] name = new string[Nparametter];
           object[] value = new object[Nparametter];
           name[0] = "@MaTaiLieu";
           value[0] = maTaiLieu.MaTaiLieu;
           name[1] = "@TenTaiLieu";
           value[1] = tenTaiLieu.TenTaiLieu;
           name[2] = "@TacGia";
           value[2] = tacGia.TacGia;
           name[3] = "@MaTheLoai";
           value[3] = maTheLoai.MaTheLoai;
           name[4] = "@MaNhaXuatBan";
           value[4] = maNhaXuatBan.MaNhaXuatBan;
           name[5] = "@NamXuatBan";
           value[5] = namXuatBan.NamXuatBan;
           name[6] = "@NoiDung";
           value[6] = noiDung.NoiDung;
           name[7] = "@MaNgonNgu";
           value[7] = maNgonNgu.MaNgonNgu;
           name[8] = "@SoTrang";
           value[8] = soTrang.SoTrang;
           name[9] = "@LanTaiBan";
           value[9] = lanTaiBan.LanTaiBan;
           name[10] = "@GiaBia";
           value[10] = giaBia.GiaBia;
           name[11] = "@SoLuong";
           value[11] = soLuong.SoLuong;
           //name[12] = "@TinhTrang";
           //value[12] = tinhTrang.TinhTrang;
           name[12] = "@MaViTri";
           value[12] = maViTri.MaViTri;
           name[13] = "@NgayCapNhat";
           value[13] = ngayCapNhat.NgayCapNhat;
           return kn.update("Update_TaiLieu", name, value, Nparametter);
       }
       public int delete_TaiLieu(TaiLieu_Public maTaiLieu)
       {
           int Nparametter = 1;
           string[] name = new string[Nparametter];
           object[] value = new object[Nparametter];
           name[0] = "@MaTaiLieu";
           value[0] = maTaiLieu.MaTaiLieu;
           return kn.update("Delete_TaiLieu", name, value, Nparametter);
       }
       public int Update_TaiLieu_TinhTrang(TaiLieu_Public maTaiLieu, TaiLieu_Public tinhTrang)
       {
           int Nparametter = 2;
           string[] name = new string[Nparametter];
           object[] value = new object[Nparametter];
           name[0] = "@MaTaiLieu";
           value[0] = maTaiLieu.MaTaiLieu;
           name[1] = "@TinhTrang";
           value[1] = tinhTrang.TinhTrang;
           return kn.update("Update_tbl_TaiLieu_TinhTrang", name, value, Nparametter);
       }
       public int update_TaiLieu_SoLuong(TaiLieu_Public maTaiLieu, TaiLieu_Public soLuong)
       {
           int Nparametter = 2;
           string[] name = new string[Nparametter];
           object[] value = new object[Nparametter];
           name[0] = "@MaTaiLieu";
           value[0] = maTaiLieu.MaTaiLieu;
           name[1] = "@SoLuong";
           value[1] = soLuong.SoLuong;
           return kn.update("update_TaiLieu_SoLuong", name, value, Nparametter);
       }
       
    }
}
